import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// import { resolve } from 'path'
import Components from 'unplugin-vue-components/vite'
import { VantResolver } from 'unplugin-vue-components/resolvers'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(),
    Components({
      resolvers: [VantResolver()],
    })
  ],
  // resolve: {
  //   alias: {
  //     '@': resolve(__dirname, 'src'),
  //     '@components': resolve(__dirname, 'src/components'),
  //     '@views': resolve(__dirname, 'src/views'),
  //     '@assets': resolve(__dirname, 'src/assets'),
  //     '@utils': resolve(__dirname, 'src/utils'),
  //     '@/stores': resolve(__dirname, 'src/stores')
  //   }
  // },
  server: {
    host: '0.0.0.0', // 允许IP访问
    port: 3000, // 指定端口号
    open: true, // 自动打开浏览器
    proxy: {
      // 配置代理
      '/api': {
        target: 'http://localhost:8080', // 后端服务器地址
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      }
    }
  }
})